home *** CD-ROM | disk | FTP | other *** search
/ Euroscene 1 / Euroscene 1.iso / resource / pchglib_11.lha / FastDecomp.a < prev    next >
Text File  |  1990-07-24  |  2KB  |  98 lines

  1.  
  2.         CSECT text,0,,1,2
  3.  
  4.         XDEF    PCHG_FastDecomp
  5.  
  6. ;****** pchg.lib/PCHG_FastDecomp ******************************************
  7. ;
  8. ;   NAME
  9. ;       PCHG_FastDecomp -- Decompress a PCHG chunk, fast.
  10. ;
  11. ;   SYNOPSIS
  12. ;       PCHG_FastDecomp(Source, Dest, TreeCode, OriginalSize);
  13. ;                        A0      A1      A2        D0
  14. ;
  15. ;       VOID PCHG_FastDecomp(APTR, APTR, WORD *, ULONG);
  16. ;
  17. ;       PCHG_CFastDecomp(Source, Dest, TreeCode, OriginalSize);
  18. ;
  19. ;       VOID PCHG_CFastDecomp(APTR, APTR, WORD *, ULONG);
  20. ;
  21. ;   FUNCTION
  22. ;       Unpack reasonably fast a PCHG chunk. This routine will
  23. ;       never bypass the OriginalSize limit while writing to
  24. ;       Dest.
  25. ;
  26. ;   INPUTS
  27. ;       Source        - The PCHG compressed data (just after the
  28. ;                       PCHGCompHeader).
  29. ;       Dest          - A block of memory OriginalSize bytes long
  30. ;                       which will contain the unpacked data.
  31. ;       TreeCode      - A pointer to the last word of the code
  32. ;                       of the tree used when compressing the data.
  33. ;                       If you're unpacking a standard PCHG chunk,
  34. ;                       you should set this entry to
  35. ;                       (char *)(PCHGCompHeader+1)+PCHGCompHeader->TreeSize-2
  36. ;       OriginalSize  - The original length of the compressed data.
  37. ;                       If you're unpacking a standard PCHG chunk,
  38. ;                       you should set this entry to
  39. ;                       PCHGCompHeader->OriginalSize
  40. ;
  41. ;   RESULT
  42. ;       None.
  43. ;
  44. ;   EXAMPLE
  45. ;
  46. ;   NOTES
  47. ;
  48. ;   BUGS
  49. ;
  50. ;   SEE ALSO
  51. ;
  52. ;****************************************************************************
  53. ;
  54. ;
  55. ;  void __asm PCHG_FastDecomp(    register __a0 void *Source,
  56. ;                register __a1 void *Dest,
  57. ;                register __a2 WORD *TreeCode,
  58. ;                register __d0 ULONG OriginalSize);
  59. ;
  60. ;
  61. ; d1: bits in longword
  62. ; d2: longword
  63. ; d3: value fetched
  64. ; a3: pointer in the tree
  65.  
  66. PCHG_FastDecomp    movem.l    d2/d3/a3,-(a7)
  67.  
  68.         moveq    #0,d1
  69.         move.l    a2,a3
  70.         bra.s    Loop
  71.  
  72. OffsetPointer    add.w    d3,a3
  73.  
  74. Loop        dbra    d1,StillBits
  75.         move.l    (a0)+,d2
  76.         moveq    #31,d1
  77.  
  78. StillBits    add.l    d2,d2
  79.         bcc.s    Case0
  80.  
  81.         move.w    (a3),d3
  82.         bmi.s    OffsetPointer
  83.  
  84. StoreValue    move.b    d3,(a1)+
  85.         move.l    a2,a3
  86.         subq.l    #1,d0
  87.         bne.s    Loop
  88.         movem.l    (a7)+,d2/d3/a3
  89.         rts
  90.  
  91. Case0        move.w    -(a3),d3
  92.         bmi.s    Loop
  93.         btst    #8,d3
  94.         bne.s    StoreValue
  95.         bra.s    Loop
  96.  
  97.         END
  98.